package com.great.codewars;

//十进制数转二进制并返回1的个数
public class BitCount {
	public static int countBits(int n) {
		return Integer.bitCount(n);
	}

	public static int countBits1(int n) {
		return Integer.toBinaryString(n).replace("0", "").length();
	}

	public static void main(String[] args) {
		//5
		System.out.println(BitCount.countBits(1234));
		//1
		System.out.println(BitCount.countBits(4));
		//3
		System.out.println(BitCount.countBits1(7));
		//2
		System.out.println(BitCount.countBits(9));
		//2
		System.out.println(BitCount.countBits(10));
	}
}
